//
// Created by xunx on 2018/12/8.
//

#include "Application.h"
#include "Window.h"
#include "Resource.h"

Application::Application(int width, int height, const char* title) {
    win = new Window(width, height, title);
    Resource::InitResource();
}

Application::~Application() {
    delete win;
}

void Application::Run() {
    float lastTime = 0;
    float currTime = 0;
    float deltaTime = 0;
    while (win->WindowShouldClose()) {
        currTime = glfwGetTime();
        deltaTime = currTime - lastTime;
        if (deltaTime > 1.0f / 30.f) {
            win->Update();
            lastTime = currTime;
        }
        win->GameTick(deltaTime);
    }
    glfwTerminate();
}
